package com.example.livedata.livedata;

import android.arch.lifecycle.LiveData;
import android.os.Handler;
import android.os.Message;

import com.example.livedata.entity.UserInfo;


public class UserLiveData extends LiveData<UserInfo> {
    UserInfo userInfo;

    @Override
    public void setValue(UserInfo value) {
        userInfo = value;
        handler.sendEmptyMessage(1);
    }

    Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            userInfo.uName += 1;
            UserLiveData.super.setValue(userInfo);

            sendEmptyMessageDelayed(1, 5000);
        }
    };

}
